import uuid

from django.db import models
from user.models import User


# Create your models here.

class PWNote(models.Model):
    #user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='用户')
    pwuser = models.CharField(max_length=128, default=None, verbose_name='用户名')
    pwdata = models.CharField(max_length=128, verbose_name='密码')
    remarks = models.CharField(max_length=128, verbose_name="备注")
    platform = models.CharField(max_length=128, verbose_name="平台", null=True)
    is_delete = models.BooleanField(default=False, verbose_name="删除")
    
    class Meta:
        db_table = 'tb_pwnote'
        verbose_name = '密码本'
        verbose_name_plural = verbose_name
    
    def get_user_by_id(self, id):
        user = User.objects.get(id=id)
        if user != None:
            return user.name
    
    # def __str__(self):
    #     user_name = self.get_user_by_id(self.user)
    #     if user_name!=None:
    #         return """{"id":{},"pwdata":"{}","pwuser":{},"remarks":"{}"}""".format(self.id,self.pwdata,self.pwuser,self.remarks)
    #     return None
